cmake_minimum_required(VERSION 2.8)
project(jf_obj_recog)

add_compile_options(-std=c++11)
add_compile_options(-pthread)
#add_compile_options(-fPIC)

option(USE_GPU "Set to switch to build use GPU"  ON)
if(USE_GPU)    
	#add_definitions(-DUSE_GPU)
	add_definitions(-DUSE_CUDNN)
endif()

find_package(OpenCV REQUIRED)

file(GLOB_RECURSE SOURCE_FILES src/*.cpp)
file(GLOB_RECURSE HEADER_FILES include/*.h)

include_directories(
	#/home/jetflow/software/caffe-1.0/include
	/usr/local/cuda/include
	/usr/local/include
	${OpenCV_INCLUDE_DIRS}
    include
)

option(USE_ROS "use ros"  ON)
if(USE_ROS)
	find_package(catkin REQUIRED COMPONENTS roscpp)	
	include_directories(
		${catkin_INCLUDE_DIRS}
	)
	catkin_package(
		INCLUDE_DIRS include
		LIBRARIES jf_obj_recog
	)
endif()

if(USE_GPU)
	cuda_add_library(${PROJECT_NAME} SHARED
		${SOURCE_FILES}
		${HEADER_FILES}
		${CU_FILES}
	)
else()
	add_library(${PROJECT_NAME} SHARED
		${SOURCE_FILES}
		${HEADER_FILES}
	)
endif()

# 指定动态库版本
# VERSION 动态库版本
# SOVERSION API版本
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION 0.1.0 SOVERSION 0)

target_link_libraries(${PROJECT_NAME}
    ${OpenCV_LIBRARIES}
	/usr/local/lib/libcaffe.so
)

if(USE_ROS)
else()
	install(TARGETS ${PROJECT_NAME}
		DESTINATION lib)
	install(FILES include/obj_recog.h
        DESTINATION include)
endif()